package com.example.demo.utils.json;

import com.alibaba.fastjson.JSONObject;
import com.example.demo.utils.reflection.ReflectionUtils;

import java.util.List;

public class BeanTransformer extends JSONObjectTransformer {
	private String[] objFields = null;
	private String[] jsonFields = null;

	public BeanTransformer(Class<?> clazz) {
		this(ReflectionUtils.findBeanNames(clazz));
	}

	public BeanTransformer(List<String> fields) {
		this(fields.toArray(new String[0]));
	}

	public BeanTransformer(String[] objFields) {
		this(objFields, objFields);
	}

	public BeanTransformer(String[] objFields, String[] jsonFields) {
		this.objFields = objFields;
		this.jsonFields = jsonFields;
	}

	@Override
	public JSONObject to(Object o) {
		return JSONUtils.toJSONObject(o, objFields, jsonFields);
	}

	@Override
	public <T> T from(Class<T> clazz, JSONObject o) {
		return null;
	}
}
